package com.example.productviewserviceribbon.controller;

import com.example.productviewserviceribbon.dao.entity.Product;
import com.example.productviewserviceribbon.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class ProductController {
    @Autowired
    private ProductService productService;
    @RequestMapping("/products")
    public String listProducts(Model model){
        List<Product> products=this.productService.listProducts();
        model.addAttribute("products",products);
        return "products";
    }
}
